/**********************************************************
 * LocationCategoriesAction.java
 *
 * Created by punam
 * Last modified Date: Aug 29, 2008 1:03:51 PM by punam
 * Revision: <svn revision #>
 * Version : 0.1
 * Copyright (c) 2008 - 2009 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.action;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.hibernate.HibernateException;
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.GenericJDBCException;

import com.opensymphony.xwork2.ActionContext;
import com.printeverywhere.delegator.CommonFunctionDelegator;
import com.printeverywhere.delegator.LocationCategoriesServiceDelegator;
import com.printeverywhere.dto.CategoryType;
import com.printeverywhere.dto.LocationCategories;
import com.printeverywhere.util.AdminConstants;

/**
 * LocationCategoriesAction class.
 *
 * @author punam
 */
public class LocationCategoriesAction extends AdminSystemManagement implements
		ServletRequestAware {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/** The logger. */
	private static Logger logger = Logger
			.getLogger(LocationCategoriesAction.class);

	/** The request. */
	private HttpServletRequest request;

	/** The location categories list. */
	private List<LocationCategories> locationCategoriesList;
	private List<LocationCategories> tempLocationCategoriesList;
	private List<LocationCategories> tempList = new ArrayList<LocationCategories>();
	private String parentId = AdminConstants.NONE;
//	private List<CategoryType> categoryTypesList;

	/** The location categories. */
	private LocationCategories locationCategories;

	/** The location categories map. */
	private Map<String, LocationCategories> locationCategoriesMap;

	/** The category area. */
	private String categoryArea = AdminConstants.BLANK;

	/** The category id. */
	private Integer categoryId;

	/** The parent category id. */
	private Integer parentCategoryId;

	/** The category teaser. */
	private Boolean categoryTeaser = AdminConstants.FALSE;

	/** The type. */
	private CategoryType type;

	/** The sort order. */
	private Long sortOrder = 0L;

	/** The category name. */
	private String categoryName;

	/** The description. */
	private String description = AdminConstants.BLANK;

	/** The category names. */
	private List<LocationCategories> categoryNames = new ArrayList<LocationCategories>();

	private List<Integer> breadCrumbIdList = new ArrayList<Integer>();

	/** The category names to delete. */
	private List<String> categoryNamesToDelete = new ArrayList<String>();

	/** The index. */
	private int index = 0;

	public String update;

	private boolean subCategory = false;

	/**
	 * This method will display all the locationCategories.
	 *
	 * @return the string
	 *
	 * @throws Exception
	 *             the exception
	 */
	@SuppressWarnings("unchecked")
	public String execute() throws Exception {
		logger.info(AdminConstants.IN_EXECUTE_METHOD);
		try {
			getAllCategories();
			displayLocationcategories();
		} catch (Exception e) {
			logger.error(AdminConstants.ERROR_IN_DISPLAYING_THE_RECORD
					+ e.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}

	/**
	 * Sets the LocationCategories object with the value from database based on
	 * the [asses categoryId.
	 *
	 * @return string
	 */
	@SuppressWarnings("unchecked")
	public String setForInsertOrUpdateCategory() {
		logger.info(" In method setForInsertOrUpdateCategory.".intern());
		try {
			if (categoryId != null) {
					locationCategories = getLocationCategoriesFromCategoryId(categoryId);
					breadCrumbIdList = LocationCategoriesServiceDelegator
							.getBreadCrumbList(locationCategories, getLocationCategoriesFromCategoryId(locationCategories.getMainParentId()));
					for (Iterator iterator = breadCrumbIdList.iterator(); iterator
							.hasNext();) {
						int id = Integer.valueOf(iterator.next().toString());
						LocationCategories locationCategories = getLocationCategoriesFromCategoryId(id);
						categoryNames.add(locationCategories);
					}

					// sets the variable values from locationCategories .
					setAttributeFromLocationCategories();
//				this.categoryTypesList = (List<CategoryType>) CommonFunctionDelegator.getAllfromtable("com.printeverywhere.dto.CategoryType");
			}
		} catch (ConstraintViolationException e) {
			addActionError("Location Name already exist.");
			logger.error(AdminConstants.RECORD_NOT_ADDED + e.getMessage());
			return INPUT;
		} catch (HibernateException e) {
			logger
					.error(AdminConstants.ERROR_IN_DISPLAYING_THE_RECORD_FOR_GIVEN_CATEGORYID
							+ e.getMessage());
			return INPUT;
		}catch (Exception e) {
			logger
			.error(AdminConstants.ERROR_IN_DISPLAYING_THE_RECORD_FOR_GIVEN_CATEGORYID
					+ e.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}

	/**
	 * Updates the category for the given categoryId. Calculates the sequence,
	 * level, mainParentId and updates the value in table.
	 *
	 * @return the string
	 */
	public String updateCategory() {
		// Sets LocationCategories fields from local variables.
		try {
			setAttributeToLocationCategories();
			LocationCategories parent = getLocationCategoriesFromCategoryId(parentCategoryId);
			updateLevelSequenceMainParent(parent, AdminConstants.EDIT);
			if(locationCategories.getSortOrder().equals(AdminConstants.NONE)){
				locationCategories.setSortOrder(Long.valueOf(AdminConstants.ZERO_NUMBER));
			}
			if(locationCategories.getCategoryName().equals(AdminConstants.NONE)){
				addActionError("Location Name required.".intern());
				logger.error(AdminConstants.ERROR_IN_UPDATING_THE_RECORD);
				return INPUT;
			}
			LocationCategoriesServiceDelegator.update(locationCategories);
		} catch (ConstraintViolationException e) {
			addActionError("Location Name already exist.".intern());
			logger.error(AdminConstants.ERROR_IN_UPDATING_THE_RECORD
					+ e.getMessage());
			return INPUT;
		}catch (HibernateException e) {
			addActionError("Enter Location Name upto 50 characters.");
			logger.error(AdminConstants.RECORD_NOT_ADDED + e.getMessage());
			return INPUT;
		} catch (NullPointerException e) {
			addActionError("Enter value for parentcategoryid".intern());
			logger.error(AdminConstants.ERROR_IN_UPDATING_THE_RECORD
					+ e.getMessage());
			return INPUT;
		}catch (Exception e) {
			logger.error(e.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}

	/**
	 * LocationCategories and all its subCategories are displayed for delete
	 * confirmation.
	 *
	 * @return the string
	 */
	public String displayAllCategory() {
		logger.info("In displayAllCategory method".intern());
		try {
			if (categoryId != null) {
				locationCategories = getLocationCategoriesFromCategoryId(categoryId);
				String display = AdminConstants.NONE
						+ locationCategories.getCategoryName()
						+ AdminConstants.OPEN_PARENTHESE
						+ (locationCategories.getLocationCategorieses().size() > 0 ? locationCategories
								.getLocationCategorieses().size() - 1
								: 0) + AdminConstants.CLOSE_PARENTHESE;
				categoryNamesToDelete.add(display);
				categoryNamesToDelete = LocationCategoriesServiceDelegator
						.show(locationCategories, AdminConstants.THREE_DASHES,
								categoryNamesToDelete);
				logger.info(" List size of the object to be deleted : "
						.intern()
						+ categoryNamesToDelete.size());
			}
		} catch (HibernateException e) {
			addActionError("Error in displaying records for category manager."
					.intern());
			logger.error(AdminConstants.ERROR_IN_DISPLAYING_THE_RECORD
					+ e.getMessage());
			return INPUT;
		}catch (Exception e) {
			logger.error(e.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}

	/**
	 * New Categories are added to location_categories table.
	 *
	 * @return String
	 */
	public String addNewCategories() {
		logger.info("In addNewCategories method. ");
		try {
			// Splits the categoryArea by new to add new categories.
			String[] categories = categoryArea.split(AdminConstants.NEW_LINE);
			for (int index = 0; index < categories.length; index++) {
				if (categories[index].trim().length() > 0) {
					categoryName = categories[index].trim();
					setAttributeToLocationCategories();
					type = new CategoryType();
					type.setId(2);
					locationCategories.setCategoryType(type);
					locationCategories
							.setLocationCategories(locationCategories);
					locationCategories.setLevel(AdminConstants.ONE_NUMBER);

					// set mainParentId
					locationCategories.setMainParentId(locationCategories
							.getCategoryId());

					// Adds the maximum sequence to newly added category.

					locationCategories
							.setSequence(LocationCategoriesServiceDelegator.getMaxSequence());
					// Sets the ParentCategory in case new category is added
					// under
					// any category.
					if (categoryId != null) {
						parentId = locationCategories.getLocationCategories().getCategoryId().toString();
						LocationCategories locationCategoriesParent = getLocationCategoriesFromCategoryId(categoryId);
						updateLevelSequenceMainParent(locationCategoriesParent
								, AdminConstants.ADD);
					}
					LocationCategoriesServiceDelegator.add(locationCategories);

					// Setting mainParentId
					if (locationCategories.getMainParentId() == null) {
						locationCategories.setMainParentId(locationCategories
								.getCategoryId());
						LocationCategoriesServiceDelegator
								.update(locationCategories);
					}
					logger.info(AdminConstants.NEW_CATEGORY_INSERTED);
				}else{
					displayLocationcategories();
					if (categoryId != null) {
						addActionError("Please, Enter sublocation-name.");
					}else {
						addActionError("Please, Enter Location-name.");
					}
					return INPUT;
				}
			}
		} catch (GenericJDBCException e) {
			displayLocationcategories();
			addActionError("Enter Category Name upto 50 characters.");
			logger.error(AdminConstants.RECORD_NOT_ADDED + e.getMessage());
			return INPUT;
		} catch (ConstraintViolationException e) {
			displayLocationcategories();
			addActionError("Category Name already exist: " + categoryName);
			logger.error(AdminConstants.RECORD_NOT_ADDED + e.getMessage());
			return INPUT;
		} catch (HibernateException e) {
			displayLocationcategories();
			addActionError("Enter Proper Data.");
			logger.error(AdminConstants.RECORD_NOT_ADDED + e.getMessage());
			return INPUT;
		}catch (Exception e) {
			logger.error(e.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}

	/**
	 * User is confirm to delete the categories and all its subcategories
	 * displayed, the method will delete the LocationCategory and all its
	 * subCategories where the given id matches for parentCategoryId, categoryId
	 * or mainParentId.
	 *
	 * @return the string
	 */
	public String deleteCategory() {
		logger.info("In deleteCategory method.".intern());
		try {
			// Deletes all category for where categoryId, mainParentId,
			// parentCategoryId matches for given id.
			if (categoryId != null) {
				this.locationCategories = getLocationCategoriesFromCategoryId(categoryId);
				LocationCategoriesServiceDelegator.delete(categoryId);
			}
		} catch (HibernateException e) {
			addActionError(AdminConstants.ERROR_IN_DELETING_THE_RECORD);
			logger.error(AdminConstants.ERROR_IN_DELETING_THE_RECORD
					+ e.getMessage());
			return INPUT;
		}catch (Exception e) {
			logger.error(e.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}
	public static void main(String[] args) {
		List valuesToSort = new ArrayList (  ) ;
	     valuesToSort.add ( new Integer ( 1 )  ) ;
	     valuesToSort.add ( new Integer ( 5 )  ) ;
	     valuesToSort.add ( new Integer ( 2 )  ) ;
	     Collections.sort ( valuesToSort, getComparator()  ) ;
	     System.out.println ( valuesToSort ) ;
	    }


	   public static Comparator getComparator (  )   {
	     return new Comparator (  )   {
	       public int compare ( Object o1, Object o2 )   {
	         return  (  ( Integer )  o1 ) .compareTo (  ( Integer )  o2 ) ;
	        }
	      } ;
	    }

	/**
	 * All the locationCategories are displayed to user for editing categoryName
	 * of any displayed category. User can edit more than one cateoryNames from
	 * displayed categories
	 *
	 * @return the string
	 */
	public String displayAllCategoryForEdit() {
		logger.info("In displayAllCategoryForEdit method.");
		try {
			getAllUpdateCategories();
		} catch (HibernateException e) {
			addActionError("Error in displaying all the general categories for edit."
					.intern());

			logger.error(e.getMessage());
			return INPUT;
		}catch (Exception e) {
			logger.error(e.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}

	/**
	 * Updates all the locationCategories Names in the database table.
	 *
	 * @return the string
	 */
	public String updateAllCategory() {
		logger.info("In updateAllCategory method.");
		try {
			for (LocationCategories locationCategories : this
					.getLocationCategoriesMap().values()) {
				if((locationCategories.getCategoryName().trim().equalsIgnoreCase(AdminConstants.NONE)) ||(locationCategories.getCategoryName().equalsIgnoreCase(null))){
					addActionError("Location Name can not be blank.");
					getAllUpdateCategories();
					return INPUT;
				}
				LocationCategoriesServiceDelegator.update(locationCategories);
			}
		} catch (ConstraintViolationException e) {
			addActionError("Category Name already exist. ");
			getAllUpdateCategories();
			logger.error(AdminConstants.ERROR_IN_UPDATING_THE_RECORD
					+ e.getMessage());
			return INPUT;
		}catch (HibernateException e) {
			addActionError("Enter Category Name upto 50 characters.");
			getAllUpdateCategories();
			logger.error(AdminConstants.ERROR_IN_UPDATING_THE_RECORD
					+ e.getMessage());
			return INPUT;
		}catch (Exception e) {
			logger.error(e.getMessage());
			return INPUT;
		}
		return SUCCESS;
	}

	public void getAllUpdateCategories(){
		tempLocationCategoriesList = (List<LocationCategories>) ActionContext.getContext().getApplication().get(AdminConstants.LOCATIONCATEGORIES);
		displayLocationcategories();
		this.locationCategoriesMap = new HashMap<String, LocationCategories>();
		for (LocationCategories locationCategories1 : locationCategoriesList) {
			this.locationCategoriesMap.put(String
					.valueOf(locationCategories1.getCategoryId()),
					locationCategories1);
		}
	}
	public void getAllCategories(){
		tempLocationCategoriesList = (List<LocationCategories>) ActionContext.getContext().getApplication().get(AdminConstants.LOCATIONCATEGORIES);
	}

	public void displayLocationcategories() {
		getAllCategories();
		if(update != null){
			if(categoryId != null && update.equalsIgnoreCase("true")){
				locationCategories = getLocationCategoriesFromCategoryId(categoryId);
				if(categoryId.equals(locationCategories.getLocationCategories().getCategoryId())){
//					categoryId = null;
				}
			}
		}

		if (categoryId != null) {
			subCategory = true;
			logger.info("Subcateogries for category : ".intern() + categoryId);
			tempList.clear();
			for (Iterator iterator = tempLocationCategoriesList.iterator(); iterator
					.hasNext();) {
				LocationCategories mainLocationCategories = (LocationCategories) iterator
						.next();
				if (categoryId.equals(mainLocationCategories.getCategoryId())) {
					LocationCategories tempLocationCategories = mainLocationCategories;
					for (Iterator<LocationCategories> subCategoriesIterator = tempLocationCategories
							.getLocationCategorieses().iterator(); subCategoriesIterator
							.hasNext();) {
						LocationCategories subLocationCategories = (LocationCategories) subCategoriesIterator
								.next();
						if (!categoryId.equals(subLocationCategories.getCategoryId())) {
							tempList.add(subLocationCategories);
						}
					}
				}
			}
			locationCategories = getLocationCategoriesFromCategoryId(categoryId);
			breadCrumbIdList = LocationCategoriesServiceDelegator
			.getBreadCrumbList(locationCategories, getLocationCategoriesFromCategoryId(locationCategories.getMainParentId()));
			for (Iterator<Integer> iterator = breadCrumbIdList.iterator(); iterator
					.hasNext();) {
				int id = Integer.valueOf(iterator.next().toString());
				LocationCategories locationCategories = getLocationCategoriesFromCategoryId(id);
				categoryNames.add(locationCategories);
			}logger.info(" categoryName size : " + categoryNames.size());
		} else {
			tempList.clear();
			for (Iterator iterator = tempLocationCategoriesList.iterator(); iterator
					.hasNext();) {
				LocationCategories tempLocationCategories = (LocationCategories) iterator
						.next();
				if (tempLocationCategories.getLevel() == AdminConstants.ONE_NUMBER){
					tempList.add(tempLocationCategories);
				}
			}
		}
		locationCategoriesList = tempList;
		logger.info("locationCategoriesList size : ".intern()
				+ locationCategoriesList.size());
	}
	public void updateLevelSequenceMainParent(LocationCategories tempLocationCategories, String addEdit) {
		int sequence = 0;
		int level = 0;
		int mParentId = 0;

		// Sets the sequence value of location_categories table.
		int max_sequence = LocationCategoriesServiceDelegator
				.getMaxOfChildSequence(this.categoryId, tempLocationCategories.getCategoryId());
		if (max_sequence == 0) {
			sequence = LocationCategoriesServiceDelegator
					.getParentSequence(tempLocationCategories.getCategoryId());
		} else {
			sequence = max_sequence;
		}

		// Gets the level of the categoryid.
		level = LocationCategoriesServiceDelegator
				.getLevelForGivenCategoryId(tempLocationCategories.getCategoryId());
		level = level + 1;
		if (addEdit.equals(AdminConstants.EDIT)) {
			if (categoryId.equals(tempLocationCategories.getCategoryId())) {
				level = 1;
			}
		}

		locationCategories.setLevel(level);
		sequence = sequence + 1;
		locationCategories.setSequence(sequence);
		// Set ParentCategoryId
		locationCategories.setLocationCategories(tempLocationCategories);

		// For mainParentId is null than parentId is mainParentId.
		if (tempLocationCategories.getMainParentId() == null) {
			mParentId = locationCategories.getLocationCategories()
					.getCategoryId();
		} // For parentCategoryid and categoryId are same.
		else if (tempLocationCategories.getCategoryId() == categoryId
				&& addEdit.equals(AdminConstants.EDIT)) {
			mParentId = tempLocationCategories.getCategoryId();
		} // In case main parentId is not null.
		else {
			LocationCategories tempLocationCategoriesForMpid = getLocationCategoriesFromCategoryId(tempLocationCategories.getCategoryId());
			mParentId = tempLocationCategoriesForMpid.getMainParentId();
		}

		locationCategories.setMainParentId(mParentId);

		// Update all the current sequences starting from sequence.
		LocationCategoriesServiceDelegator.updateSequences(sequence);
	}
 public LocationCategories getLocationCategoriesFromCategoryId(int categoryid){
	 try{
		 tempLocationCategoriesList = (List<LocationCategories>) ActionContext.getContext().getApplication().get(AdminConstants.LOCATIONCATEGORIES);
		LocationCategories type = new LocationCategories();
		for (Iterator<LocationCategories> iterator = tempLocationCategoriesList.iterator(); iterator.hasNext();) {
			type = (LocationCategories) iterator.next();
			if(categoryid == type.getCategoryId()){
				return type;
			}
		}
	 }catch (Exception e) {
		 addActionError(e.getMessage());
	}
		return null;
 }

 	/**
	 * Gets LocationCategoriesList.
	 *
	 * @return the location categories list
	 */
	public List<LocationCategories> getLocationCategoriesList() {
		return locationCategoriesList;
	}

	/**
	 * Sets LocationCategoriesList.
	 *
	 * @param locationCategoriesList
	 *            the location categories list
	 */
	public void setLocationCategoriesList(
			List<LocationCategories> locationCategoriesList) {
		this.locationCategoriesList = locationCategoriesList;
	}

	/**
	 * Sets the attribute values from LocationCategories object values.
	 */
	public void setAttributeFromLocationCategories() {
		this.categoryId = locationCategories.getCategoryId();
		this.parentCategoryId = locationCategories.getLocationCategories()
				.getCategoryId();
		this.categoryTeaser = locationCategories.isCategoryTeaser();
		this.type = locationCategories.getCategoryType();
		this.sortOrder = locationCategories.getSortOrder();
		this.categoryName = locationCategories.getCategoryName();
		this.description = locationCategories.getDescription();
	}

	/**
	 * Sets the variable values to LocationCategories object.
	 */
	public void setAttributeToLocationCategories() {
		int id = parentCategoryId == null ? 1 : parentCategoryId;
		this.locationCategories = new LocationCategories();
		this.locationCategories.setCategoryId(categoryId);
		this.locationCategories.setCategoryName(categoryName);
		this.locationCategories.setCategoryTeaser(categoryTeaser);
		this.locationCategories.setDescription(description);
		this.locationCategories.setSortOrder(sortOrder);
		this.locationCategories
				.setLocationCategories(getLocationCategoriesFromCategoryId(id));
		this.locationCategories.setCategoryType(type);
	}

	/**
	 * Gets the description.
	 *
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Sets the description.
	 *
	 * @param description
	 *            the new description
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.apache.struts2.interceptor.ServletRequestAware#setServletRequest(javax.servlet.http.HttpServletRequest)
	 */
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	/**
	 * Gets the category area.
	 *
	 * @return the category area
	 */
	public String getCategoryArea() {
		return categoryArea;
	}

	/**
	 * Sets the category area.
	 *
	 * @param categoryArea
	 *            the new category area
	 */
	public void setCategoryArea(String categoryArea) {
		this.categoryArea = categoryArea;
	}

	/**
	 * Gets the location categories.
	 *
	 * @return the location categories
	 */
	public LocationCategories getLocationCategories() {
		return locationCategories;
	}

	/**
	 * Sets the location categories.
	 *
	 * @param locationCategories
	 *            the new location categories
	 */
	public void setLocationCategories(LocationCategories locationCategories) {
		this.locationCategories = locationCategories;
	}

	/**
	 * Gets the category id.
	 *
	 * @return the category id
	 */
	public Integer getCategoryId() {
		return categoryId;
	}

	/**
	 * Sets the category id.
	 *
	 * @param categoryId
	 *            the new category id
	 */
	public void setCategoryId(Integer categoryId) {
		this.categoryId = categoryId;
	}

	/**
	 * Gets the parent category id.
	 *
	 * @return the parent category id
	 */
	public Integer getParentCategoryId() {
		return parentCategoryId;
	}

	/**
	 * Sets the parent category id.
	 *
	 * @param parentCategoryId
	 *            the new parent category id
	 */
	public void setParentCategoryId(Integer parentCategoryId) {
		this.parentCategoryId = parentCategoryId;
	}

	/**
	 * Gets the category teaser.
	 *
	 * @return the category teaser
	 */
	public Boolean getCategoryTeaser() {
		return categoryTeaser;
	}

	/**
	 * Sets the category teaser.
	 *
	 * @param categoryTeaser
	 *            the new category teaser
	 */
	public void setCategoryTeaser(Boolean categoryTeaser) {
		this.categoryTeaser = categoryTeaser;
	}

	/**
	 * Gets the sort order.
	 *
	 * @return the sort order
	 */
	public Long getSortOrder() {
		return sortOrder;
	}

	/**
	 * Sets the sort order.
	 *
	 * @param sortOrder
	 *            the new sort order
	 */
	public void setSortOrder(Long sortOrder) {
		this.sortOrder = sortOrder;
	}

	/**
	 * Gets the category name.
	 *
	 * @return the category name
	 */
	public String getCategoryName() {
		return categoryName;
	}

	/**
	 * Sets the category name.
	 *
	 * @param categoryName
	 *            the new category name
	 */
	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	/**
	 * Gets the location categories map.
	 *
	 * @return the location categories map
	 */
	public Map<String, LocationCategories> getLocationCategoriesMap() {
		return locationCategoriesMap;
	}

	/**
	 * Sets the location categories map.
	 *
	 * @param locationCategoriesMap
	 *            the location categories map
	 */
	public void setLocationCategoriesMap(
			Map<String, LocationCategories> locationCategoriesMap) {
		this.locationCategoriesMap = locationCategoriesMap;
	}

	/**
	 * Gets the category names.
	 *
	 * @return the category names
	 */
	public List<LocationCategories> getCategoryNames() {
		return categoryNames;
	}

	/**
	 * Sets the category names.
	 *
	 * @param categoryNames
	 *            the new category names
	 */
	public void setCategoryNames(List<LocationCategories> categoryNames) {
		this.categoryNames = categoryNames;
	}

	/**
	 * Gets the index.
	 *
	 * @return the index
	 */
	public int getIndex() {
		return index;
	}

	/**
	 * Sets the index.
	 *
	 * @param index
	 *            the new index
	 */
	public void setIndex(int index) {
		this.index = index;
	}

	/**
	 * Gets the category names to delete.
	 *
	 * @return the category names to delete
	 */
	public List<String> getCategoryNamesToDelete() {
		return categoryNamesToDelete;
	}

	/**
	 * Sets the category names to delete.
	 *
	 * @param categoryNamesToDelete
	 *            the new category names to delete
	 */
	public void setCategoryNamesToDelete(List<String> categoryNamesToDelete) {
		categoryNamesToDelete = categoryNamesToDelete;
	}

	public CategoryType getType() {
		return type;
	}

	public void setType(CategoryType type) {
		this.type = type;
	}

	public boolean isSubCategory() {
		return subCategory;
	}

	public void setSubCategory(boolean subCategory) {
		this.subCategory = subCategory;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getUpdate() {
		return update;
	}

	public void setUpdate(String update) {
		this.update = update;
	}


	/*public List<CategoryType> getCategoryTypesList() {
		return categoryTypesList;
	}

	public void setCategoryTypesList(List<CategoryType> categoryTypesList) {
		this.categoryTypesList = categoryTypesList;
	}*/
}